home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sun3.md / vmSunConst.h < prev   
C/C++ Source or Header  |  1990-09-11  |  12KB  |  323 lines

  1. /*
  2.  * vmSunConst.h --
  3.  *
  4.  *         Virtual memory constants for the Sun.  See the "Sun 2.0 Architecture 
  5.  *    Manual" for a definition of these constants.
  6.  *
  7.  * Copyright (C) 1985 Regents of the University of California
  8.  * All rights reserved.
  9.  *
  10.  *
  11.  * $Header: /sprite/src/kernel/vm/sun3.md/RCS/vmSunConst.h,v 9.2 90/02/15 09:30:25 brent Exp $ SPRITE (Berkeley)
  12.  */
  13.  
  14. #ifndef _VMSUN3CONST
  15. #define _VMSUN3CONST
  16.  
  17. /*
  18.  * Sun3 page table entry masks.
  19.  *
  20.  *    VMMACH_RESIDENT_BIT    The page is physical resident.
  21.  *    VMMACH_PROTECTION_FIELD    Access to the protection bits.
  22.  *    VMMACH_KR_PROT        Kernel read only, user no access.
  23.  *    VMMACH_KRW_PROT        Kernel read/write, user no access.
  24.  *    VMMACH_UR_PROT        Kernel read only, user read only
  25.  *    VMMACH_URW_PROT        Kernel read/write, user read/write.
  26.  *    VMMACH_DONT_CACHE_BIT    Don't cache bit.
  27.  *    VMMACH_TYPE_FIELD        The memory type field.
  28.  *    VMMACH_REFERENCED_BIT    Referenced bit.
  29.  *    VMMACH_MODIFIED_BIT    Modified bit.
  30.  *    VMMACH_PAGE_FRAME_FIELD    The hardware page frame.
  31.  */
  32. #define    VMMACH_RESIDENT_BIT    0x80000000
  33. #define    VMMACH_PROTECTION_FIELD    0x60000000
  34. #define    VMMACH_UR_PROT        0x00000000
  35. #define    VMMACH_KR_PROT        0x20000000
  36. #define VMMACH_URW_PROT        0x40000000
  37. #define    VMMACH_KRW_PROT        0x60000000
  38. #define    VMMACH_DONT_CACHE_BIT    0x10000000
  39. #define    VMMACH_TYPE_FIELD    0x0c000000
  40. #define VMMACH_REFERENCED_BIT    0x02000000
  41. #define    VMMACH_MODIFIED_BIT    0x01000000
  42. #define VMMACH_PAGE_FRAME_FIELD    0x0007ffff    
  43.  
  44. /*
  45.  * Shift to allow the type field to get set.
  46.  */
  47. #define    VmMachGetPageType(pte) (((pte) >> 26) & 3)
  48. #define    VmMachSetPageType(pte, type) (pte |= (type << 26))
  49.  
  50. /*
  51.  * Sun memory management unit constants:
  52.  *
  53.  * VMMACH_KERN_CONTEXT        The Kernel's context.
  54.  * VMMACH_NUM_CONTEXTS        The number of contexts.
  55.  * VMMACH_NUM_SEGS_PER_CONTEXT    The number of hardware segments per context.
  56.  * VMMACH_NUM_PAGES_PER_SEG_INT    The number of pages per hardware segment.
  57.  * VMMACH_NUM_PAGE_MAP_ENTRIES    The number of hardware page map entries.
  58.  * VMMACH_NUM_PMEGS        The number of page clusters that there are 
  59.  *                in the system.
  60.  * VMMACH_INV_PMEG           The page cluster number that is used to 
  61.  *                represent an invalid Pmeg.
  62.  * VMMACH_INV_SEG           The hardware segment number that is used to
  63.  *                represent an invalid hardware segment.
  64.  * VMMACH_INV_CONTEXT       The context number that is used to represent
  65.  *                an invalid context.
  66.  */
  67. #define VMMACH_KERN_CONTEXT        0
  68. #define VMMACH_NUM_CONTEXTS        8
  69. #define VMMACH_NUM_SEGS_PER_CONTEXT    2048
  70. #define VMMACH_NUM_PAGES_PER_SEG_INT    16
  71. #define VMMACH_NUM_PAGE_MAP_ENTRIES    4096
  72. #define    VMMACH_NUM_PMEGS        (VMMACH_NUM_PAGE_MAP_ENTRIES / VMMACH_NUM_PAGES_PER_SEG_INT)
  73.  
  74. /*
  75.  * The following sets of constants define the kernel's virtual address space. 
  76.  * Some of the constants are defined in machineConst.h.
  77.  *
  78.  * VMMACH_DEV_START_ADDR        The first virtual address that is used for
  79.  *                              mapping devices.
  80.  * VMMACH_DEV_END_ADDR        The last virtual address that could be used for 
  81.  *                mapping devices.
  82.  * VMMACH_DMA_START_ADDR    The first virtual address that is used for 
  83.  *                DMA buffers by devices.
  84.  * VMMACH_DMA_SIZE        The amount of space devoted to DMA buffers
  85.  * VMMACH_NET_MAP_START        The beginning of space for mapping the Intel
  86.  *                and AMD drivers.
  87.  * VMMACH_NET_MEM_START        The beginning of space for memory for the Intel
  88.  *                and AMD drivers.
  89.  * VMMACH_FIRST_SPECIAL_SEG    The first hardware segment that is used for 
  90.  *                mapping devices.
  91.  *
  92.  * The Sun3 address space looks like the following:  The hex addresses are
  93.  *    valid on most sun3s.  Those with small memories may have their
  94.  *    vmStackBaseAddr shifted down a bit (== e3fc000 on a 3/50).
  95.  *    vmMapBaseAddr and vmBlockCacheBaseAddr are computed relative to
  96.  *    the stack base, which is determined by max kernel size.
  97.  *
  98.  *    |-------------------------------|    0x00000000
  99.  *    | Trap vectors & Invalid Page    |
  100.  *    |-------------------------------|    0x00004000
  101.  *    | User Virtual Address Space    |
  102.  *         |                |
  103.  *    | Top of User stack        |
  104.  *    |-------------------------------|    0x0dfe0000 VMMACH_MAP_SEG_ADDR
  105.  *    | 1 Segment for user mappings    |    0x0e000000 MACH_KERN_START
  106.  *    |-------------------------------|    0x0e000000 MACH_STACK_BOTTOM
  107.  *    | 16K for (mapped) kernel stack    |
  108.  *    |-------------------------------|    0x0e004000 MACH_CODE_START
  109.  *         |                |
  110.  *         | Kernel Code and Data        |    (VMMACH_MAX_KERN_SIZE)
  111.  *         |                |
  112.  *    ---------------------------------    0x0e800000 vmStackBaseAddr
  113.  *    |                |    
  114.  *    | Page frames for kernel stacks |
  115.  *    |-------------------------------|    0x0ea00000 vmMapBaseAddr
  116.  *    | Mapping for Vm_MakeAccessible    |    
  117.  *    ---------------------------------    0x0ea20000
  118.  *    | Mapping for PMEG and PTE    |
  119.  *    |_______________________________|    0x0ea60000 vmBlockCacheBaseAddr
  120.  *    |                 |
  121.  *    | FS Block cache        |
  122.  *    |                 |    mack_KernEnd vmBlockCacheEndAddr
  123.  *    |-------------------------------|    0x0fd00000 VMMACH_FRAME_BUFFER
  124.  *    | Frame buffer            |
  125.  *      |-------------------------------|    0x0fe00000 VMMACH_DEV_START_ADDR
  126.  *    |                |
  127.  *    | Mapped in devices        |
  128.  *    |                |    VMMACH_DEV_END_ADDR
  129.  *    |-------------------------------|    0x0ff00000 VMMACH_DMA_START_ADDR
  130.  *    |                |
  131.  *    | Space for mapping in DMA bufs |
  132.  *    |                |
  133.  *    |-------------------------------|    0x0ffc0000 VMMACH_NET_MAP_START
  134.  *    | For mapping ethernet packets    |
  135.  *    |-------------------------------|    0x0ffe0000 VMMACH_NET_MEM_START
  136.  *    | For mapping ethernet memory    |
  137.  *    |-------------------------------|    0x0fffffff end-o-virtual-sun3
  138.  */
  139.  
  140. /*
  141.  * There is a special area of a users VAS to allow copies between two user
  142.  * address spaces.  This area sits between the beginning of the kernel and
  143.  * the top of the user stack.  It is one hardware segment wide.
  144.  */
  145. #define    VMMACH_MAP_SEG_ADDR        (MACH_KERN_START - VMMACH_SEG_SIZE)
  146.  
  147. /*
  148.  * VMMACH_MAX_KERN_SIZE defines the maximum size of the kernel code+data.
  149.  *    A variable is initialized to this, and it may be further reduced
  150.  *    so that this amount is never greater than all of physical memory.
  151.  * VMMACH_BOOT_MAP_PAGES Defines number of pages that need to be mapped
  152.  *        in during bootstrap ("pre VM setup").
  153.  */
  154. #ifdef sun3
  155. #define VMMACH_MAX_KERN_SIZE        (8192 * 1024)
  156. #define VMMACH_BOOT_MAP_PAGES        (512)
  157. #endif
  158. #ifdef sun2
  159. #define VMMACH_MAX_KERN_SIZE        (2048 * 1024)
  160. #define VMMACH_BOOT_MAP_PAGES        (1024)
  161. #endif
  162.  
  163.  
  164. #define VMMACH_FRAME_BUFFER_ADDR    0xFD00000
  165. #define VMMACH_KERN_END            VMMACH_FRAME_BUFFER_ADDR
  166. #define    VMMACH_FIRST_SPECIAL_SEG    (VMMACH_KERN_END >> VMMACH_SEG_SHIFT)
  167. #define VMMACH_DEV_START_ADDR           0xFE00000
  168. #define    VMMACH_DEV_END_ADDR        0xFEFFFFF
  169. #define    VMMACH_DMA_START_ADDR        0xFF00000
  170. #define    VMMACH_DMA_SIZE            0xC0000
  171. #define VMMACH_NET_MAP_START        0xFFC0000
  172. #define VMMACH_NET_MEM_START        0xFFE0000
  173. #define    VMMACH_INV_PMEG            (VMMACH_NUM_PMEGS - 1)
  174. #define    VMMACH_INV_SEG            VMMACH_NUM_SEGS_PER_CONTEXT
  175. #define    VMMACH_INV_CONTEXT        VMMACH_NUM_CONTEXTS
  176.  
  177. /*
  178.  * Function code constants for access to the different address spaces as
  179.  * defined by the Sun and 68010 hardware.  These constants determine which
  180.  * address space is accessed when using a "movs" instruction.
  181.  *
  182.  * VMMACH_USER_DATA_SPACE        User data space.
  183.  * VMMACH_USER_PROGRAM_SPACE    User program space
  184.  * VMMACH_MMU_SPACE            Sun-2 memory map space.
  185.  * VMMACH_KERN_DATA_SPACE        Kernel data space.
  186.  * VMMACH_KERN_PROGRAM_SPACE    Kernel program space.
  187.  * VMMACH_CPU_SPACE            Cpu space.
  188.  */
  189.  
  190. #define    VMMACH_USER_DATA_SPACE        1
  191. #define    VMMACH_USER_PROGRAM_SPACE    2
  192. #define    VMMACH_MMU_SPACE        3
  193. #define    VMMACH_KERN_DATA_SPACE        5
  194. #define    VMMACH_KERN_PROGRAM_SPACE    6
  195. #define    VMMACH_CPU_SPACE        7
  196.  
  197. /*
  198.  * Masks for access to different parts of mmu space.
  199.  *
  200.  * VMMACH_PAGE_MAP_OFF         Offset to hardware page map entries
  201.  * VMMACH_SEG_MAP_OFF         Offset to hardware segment map entries
  202.  * VMMACH_CONTEXT_OFF         Offset to context register
  203.  * VMMACH_DIAGNOSTIC_REG    The address of the diagnostic register.
  204.  * VMMACH_BUS_ERROR_REG        The address of the bus error register.
  205.  * VMMACH_SYSTEM_ENABLE_REG    The address of the system enable register.
  206.  * VMMACH_ETHER_ADDR        Address of ethernet address in the id prom.
  207.  * VMMACH_MACH_TYPE_ADDR    Address of machine type in the id prom.
  208.  * VMMACH_IDPROM_INC        Amount to increment an address when stepping
  209.  *                through the id prom.
  210.  */
  211.  
  212. #define    VMMACH_PAGE_MAP_OFF        0x10000000
  213. #define    VMMACH_SEG_MAP_OFF        0x20000000
  214. #define    VMMACH_CONTEXT_OFF        0x30000000
  215. #define VMMACH_SYSTEM_ENABLE_REG    0x40000000
  216. #define VMMACH_BUS_ERROR_REG        0x60000000
  217. #define VMMACH_DIAGNOSTIC_REG        0x70000000
  218. #define VMMACH_ETHER_ADDR        0x02
  219. #define VMMACH_MACH_TYPE_ADDR        0x01
  220. #define VMMACH_IDPROM_INC        0x01
  221.  
  222. /*
  223.  * The highest virtual address useable by the kernel for both machine type
  224.  * 1 and machine type 2.
  225.  */
  226.  
  227. #define    VMMACH_MACH_TYPE1_MEM_END    0xF40000
  228. #define    VMMACH_MACH_TYPE2_MEM_END    0x1000000
  229. #define    VMMACH_MACH_TYPE3_MEM_END    0x10000000
  230.  
  231. /*
  232.  * Masks to extract good bits from the virtual addresses when accessing
  233.  * the page and segment maps.
  234.  */
  235.  
  236. #define    VMMACH_PAGE_MAP_MASK    0xFFFFe000
  237. #define    VMMACH_SEG_MAP_MASK        0xFFFe0000
  238.  
  239. /*
  240.  * Mask to get only the low order three bits of a context register.
  241.  */
  242.  
  243. #define    VMMACH_CONTEXT_MASK        0x7
  244.  
  245. /*
  246.  * Hardware dependent constants for pages and segments:
  247.  *
  248.  * VMMACH_CLUSTER_SIZE      The number of hardware pages per virtual page.
  249.  * VMMACH_CLUSTER_SHIFT     The log base 2 of VMMACH_CLUSTER_SIZE.
  250.  * VMMACH_PAGE_SIZE        The size of each virtual page.
  251.  * VMMACH_PAGE_SIZE_INT        The size of each hardware page.
  252.  * VMMACH_PAGE_SHIFT        The log base 2 of VMMACH_PAGE_SIZE.
  253.  * VMMACH_PAGE_SHIFT_INT    The log base 2 of VMMACH_PAGE_SIZE_INT
  254.  * VMMACH_OFFSET_MASK        Mask to get to the offset of a virtual address.
  255.  * VMMACH_OFFSET_MASK_INT    Mask to get to the offset of a virtual address.
  256.  * VMMACH_PAGE_MASK        Mask to get to the Hardware page number within a
  257.  *                hardware segment.
  258.  * VMMACH_SEG_SIZE        The size of each hardware segment.
  259.  * VMMACH_SEG_SHIFT        The log base 2 of VMMACH_SEG_SIZE.
  260.  * VMMACH_NUM_PAGES_PER_SEG    The number of virtual pages per segment.
  261.  */
  262.  
  263. #define VMMACH_CLUSTER_SIZE     1
  264. #define VMMACH_CLUSTER_SHIFT    0
  265. #define VMMACH_PAGE_SIZE        (VMMACH_CLUSTER_SIZE * VMMACH_PAGE_SIZE_INT)
  266. #define    VMMACH_PAGE_SIZE_INT    8192
  267. #define VMMACH_PAGE_SHIFT    (VMMACH_CLUSTER_SHIFT + VMMACH_PAGE_SHIFT_INT)
  268. #define VMMACH_PAGE_SHIFT_INT    13
  269. #define VMMACH_OFFSET_MASK    0x1fff
  270. #define VMMACH_OFFSET_MASK_INT    0x1fff
  271. #define VMMACH_PAGE_MASK    0x1E000    
  272. #define    VMMACH_SEG_SIZE        0x20000
  273. #define VMMACH_SEG_SHIFT    17    
  274. #define    VMMACH_NUM_PAGES_PER_SEG (VMMACH_NUM_PAGES_PER_SEG_INT / VMMACH_CLUSTER_SIZE)
  275.  
  276. /*
  277.  * Sun3's don't have a cache.
  278.  * Zero values here confuse lint.
  279.  */
  280.  
  281. #ifdef lint
  282. #define VMMACH_CACHE_LINE_SIZE    1
  283. #define VMMACH_NUM_CACHE_LINES    1
  284. #define VMMACH_CACHE_SIZE     1
  285. #else
  286. #define VMMACH_CACHE_LINE_SIZE    0
  287. #define VMMACH_NUM_CACHE_LINES    0
  288. #define VMMACH_CACHE_SIZE     0
  289. #endif
  290.  
  291. /*
  292.  * The size that page tables are to be allocated in.  This grows software
  293.  * segments in 256K chunks.  The page tables must grow in chunks that are 
  294.  * multiples of the hardware segment size.  This is because the heap and 
  295.  * stack segments grow towards each other in VMMACH_PAGE_TABLE_INCREMENT 
  296.  * sized chunks.  Thus if the increment wasn't a multiple of the hardware 
  297.  * segment size then the heap and stack segments could overlap on a 
  298.  * hardware segment.
  299.  */
  300.  
  301. #define    VMMACH_PAGE_TABLE_INCREMENT    (((256 * 1024 - 1) / VMMACH_SEG_SIZE + 1) * VMMACH_NUM_PAGES_PER_SEG)
  302.  
  303. /*
  304.  * The maximum number of kernel stacks.  There is a limit because these
  305.  * use part of the kernel's virtual address space.
  306.  */
  307. #define VMMACH_MAX_KERN_STACKS    128
  308.  
  309. /*
  310.  * Definitions for shared memory.
  311.  * VMMACH_USER_SHARED_PAGES is the number of pages allocated for shared
  312.  *    memory.
  313.  * VMMACH_SHARED_BLOCK_SIZE is the block size in which shared memory is
  314.  *    allocated.  This is a multiple of 128K to avoid cache aliasing.
  315.  * VMMACH_SHARED_START ADDR is the address at which shared memory starts.
  316.  */
  317. #define VMMACH_USER_SHARED_PAGES    8192
  318. #define VMMACH_SHARED_BLOCK_SIZE    0x20000
  319. #define VMMACH_SHARED_START_ADDR    (VMMACH_MAP_SEG_ADDR-VMMACH_USER_SHARED_PAGES*VMMACH_PAGE_SIZE)
  320. #define    VMMACH_SHARED_NUM_BLOCKS    (VMMACH_USER_SHARED_PAGES*VMMACH_PAGE_SIZE/VMMACH_SHARED_BLOCK_SIZE)
  321.  
  322. #endif /* _VMSUN3CONST */
  323.